<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>API测试</title>
</head>
<body>
    <h1>API测试</h1>
    <button onclick="testSensorData()">测试 /api/sensor-data</button>
    <button onclick="testGetData()">测试 /get_data</button>
    <pre id="output"></pre>

    <script>
        async function testSensorData() {
            try {
                const response = await fetch('/api/sensor-data');
                const data = await response.json();
                document.getElementById('output').textContent = JSON.stringify(data, null, 2);
            } catch (error) {
                document.getElementById('output').textContent = '错误: ' + error.message;
            }
        }

        async function testGetData() {
            try {
                const response = await fetch('/get_data');
                const data = await response.json();
                document.getElementById('output').textContent = JSON.stringify(data, null, 2);
            } catch (error) {
                document.getElementById('output').textContent = '错误: ' + error.message;
            }
        }
    </script>
</body>
</html> 